<template>
  <view class="container">
    <!-- 商品信息 -->
    <view class="product-section">
      <view class="product-item">
        <image :src="orderInfo.img" mode="aspectFill"></image>
        <view class="product-info">
          <view class="info-row">
            <text class="product-title">{{ orderInfo.title }}</text>
          </view>
          <view class="info-row">
            <text class="product-spec">{{ orderInfo.norm }}</text>
          </view>
          <view class="info-row">
            <text class="product-count">数量：{{ orderInfo.num }}</text>
            <text class="product-price">¥{{ orderInfo.price }}</text>
          </view>
        </view>
      </view>
    </view>
    
    <!-- 操作按钮 -->
    <view class="action-section">
      <view class="action-buttons">
        <button class="action-btn contact-btn">
          <uni-icons type="headphones" size="30" color="#FF8000"></uni-icons>
          联系客服</button>
        <button class="action-btn complaint-btn">
          <uni-icons type="email-filled" size="30" color="#FF8000"></uni-icons>
          投诉&建议</button>
      </view>
    </view>
    <!-- 订单信息 -->
    <view class="order-info-section">
      <view class="info-item">
        <text class="info-label">订单编号：</text>
        <text class="info-value">{{ orderInfo.code }}</text>
      </view>
      <view class="info-item">
        <text class="info-label">下单时间：</text>
        <text class="info-value">{{ orderInfo.createtime }}</text>
      </view>
      <view class="info-item">
        <text class="info-label">收货地址：</text>
        <text class="info-value">{{ orderInfo.address || '未知' }}</text>
      </view>
    </view>
    
  </view>
</template>

<script>
import uniIcons from '@dcloudio/uni-ui/lib/uni-icons/uni-icons.vue';

export default {
  components: {
    uniIcons
  },
  data() {
    return {
      orderInfo: {}
    };
  },
  
  onLoad(options) {
    // 从页面参数中获取订单信息
    if (options.orderInfo) {
      try {
        // 解析传递过来的订单信息
        this.orderInfo = JSON.parse(decodeURIComponent(options.orderInfo));
      } catch (e) {
        console.error('解析订单信息失败:', e);
        uni.showToast({
          title: '订单信息解析失败',
          icon: 'none'
        });
      }
    } else {
      console.warn('未接收到订单信息');
      uni.showToast({
        title: '未找到订单信息',
        icon: 'none'
      });
    }
  },
  
  methods: {
    goBack() {
      uni.navigateBack();
    }
  }
};
</script>

<style scoped>
.container {
  width: 100%;
  min-height: 100vh;
  background-color: #f5f5f5;
  padding-bottom: 20rpx;
}

/* 顶部导航栏 */
.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 88rpx;
  background-color: #fff;
  padding: 0 30rpx;
  position: sticky;
  top: 0;
  z-index: 999;
  box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
}

.nav-back {
  width: 44rpx;
  height: 44rpx;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-title {
  font-size: 32rpx;
  font-weight: bold;
  color: #333;
}

.nav-placeholder {
  width: 44rpx;
}

/* 订单状态 */
.order-status-section {
  background-color: #fff;
  margin: 20rpx;
  border-radius: 10rpx;
  padding: 30rpx;
}

.status-header {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 20rpx;
}

.status-text {
  font-size: 36rpx;
  font-weight: bold;
  color: #ff6600;
}

/* 收货地址 */
.address-section {
  background-color: #fff;
  margin: 20rpx;
  border-radius: 10rpx;
  padding: 30rpx;
}

.address-header {
  display: flex;
  align-items: center;
  margin-bottom: 20rpx;
}

.address-title {
  font-size: 28rpx;
  font-weight: bold;
  color: #333;
  margin-left: 10rpx;
}

.receiver {
  font-size: 28rpx;
  color: #333;
  font-weight: bold;
  margin-right: 20rpx;
}

.phone {
  font-size: 26rpx;
  color: #666;
}

.detail {
  font-size: 26rpx;
  color: #666;
  margin-top: 10rpx;
  display: block;
}

/* 商品信息 */
.product-section {
  background-color: #fff;
  margin: 20rpx;
  border-radius: 10rpx;
  padding: 30rpx;
}

.section-header {
  font-size: 28rpx;
  font-weight: bold;
  color: #333;
  margin-bottom: 20rpx;
}

.product-item {
  display: flex;
}

.product-item image {
  width: 180rpx;
  height: 180rpx;
  border-radius: 10rpx;
  margin-right: 20rpx;
}

.product-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 10rpx 0;
}

.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.product-title {
  font-size: 28rpx;
  color: #333;
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.product-spec {
  font-size: 24rpx;
  color: #999;
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.product-count {
  font-size: 26rpx;
  color: #666;
  margin-right: 20rpx;
}

.product-price {
  font-size: 28rpx;
  color: #ff0000;
  font-weight: bold;
}

/* 订单信息 */
.order-info-section {
  background-color: #fff;
  margin: 20rpx;
  border-radius: 10rpx;
  padding: 30rpx;
}

.info-item {
  display: flex;
  margin-bottom: 20rpx;
}

.info-item:last-child {
  margin-bottom: 0;
}

.info-label {
  font-size: 26rpx;
  color: #999;
  width: 180rpx;
}

.info-value {
  font-size: 26rpx;
  color: #333;
  flex: 1;
}

/* 操作按钮 */
.action-section {
  margin-left: 20px;
  border-radius: 10rpx;
}

.action-buttons {
  display: flex;
  justify-content: center;
  height: 50px;
}

.action-btn {
  padding: 20px 27rpx;
  font-size: 16px;
  border-radius: 15rpx;
  background-color: #fff;
  margin-left: 20rpx;
  border: 1rpx solid #ddd;
  display: flex;
  align-items: center;
  justify-content: center;
}

.contact-btn {
  color: #666;
}

.complaint-btn {
  color: #666;
}
</style>